package com.netty.cn.rpc.selfmessage.core;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * 
 * @author wangzonghui
 * @date 2023-02-24 16:33:53
 * @Description 编码类
 */
public class MyMessageEncoder extends MessageToByteEncoder<MyMessage> {
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, MyMessage myMessage, ByteBuf byteBuf) throws Exception {
        byteBuf.writeInt(myMessage.getLen());
        byteBuf.writeBytes(myMessage.getContent());
    }


}
